﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Stp.Core;
using Stp.Core.Services;
using Stp.Test.Fakes;

namespace Stp.Test
{
    [TestClass]
    public class AccountRegisterServiceTest
    {
        private FakeAccount _fAccount;
        private AccountRegisterService _ars;

        [TestInitialize]
        public void Setup()
        {
            _fAccount = new FakeAccount();
            _ars = new AccountRegisterService(_fAccount);
        }

        [TestMethod]
        public void AccountRegisterServiceTest_InvalidAcDataTest()
        {
            _fAccount.RetVerifyData = false;
            _fAccount.SetException = false;

            ActionResult aResult = _ars.Execute();

            Assert.IsFalse(aResult.IsSuccessful);
            Assert.AreEqual("Account data is not valid.", aResult.Messages);
        }

        [TestMethod]
        public void AccountRegisterServiceTest_ExceptionTest()
        {
            _fAccount.RetVerifyData = true;
            _fAccount.SetException = true;

            ActionResult aResult = _ars.Execute();

            Assert.IsFalse(aResult.IsSuccessful);
            Assert.AreEqual("Test Exception.", aResult.Messages);
        }

        [TestMethod]
        public void AccountRegisterServiceTest_AllGoodConditionTest()
        {
            _fAccount.RetVerifyData = true;
            _fAccount.SetException = false;

            ActionResult aResult = _ars.Execute();

            Assert.IsTrue(aResult.IsSuccessful);
            Assert.AreEqual(string.Empty, aResult.Messages);
        }
    }
}
